home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / StormAmigalib / stormamiga_lib / Include / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  3.8 KB  |  109 lines

  1. #ifndef FCNTL_H
  2. #define FCNTL_H
  3.  
  4. /*
  5. **          $VER: fcntl.h 1.3 (18.09.98)
  6. **             Includes Release 44.10
  7. **
  8. **     Copyright © 1996/98 by CyberdyneSystems
  9. **
  10. **            written by Matthias Henze
  11. **               All Rights Reserved
  12. */
  13.  
  14. #ifndef STORMAMIGA_H
  15.   #include <stormamiga.h>
  16. #endif
  17. #ifndef SYS_TYPES_H
  18.   #include <sys/types.h>
  19. #endif
  20.  
  21. #ifdef __cplusplus
  22.   extern "C" {
  23. #endif
  24.  
  25. /*
  26.  * File status flags: these are used by open.
  27.  * They are also used (indirectly) in the kernel file structure f_flags,
  28.  * which is a superset of the open/fcntl flags.  Open flags and f_flags
  29.  * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
  30.  * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
  31.  */
  32. /* open-only flags */
  33. #define O_RDONLY        0x0000          /* open for reading only */
  34. #define O_WRONLY        0x0001          /* open for writing only */
  35. #define O_RDWR          0x0002          /* open for reading and writing */
  36. #define O_ACCMODE       0x0003          /* mask for above modes */
  37.  
  38. #define FREAD           0x0001
  39. #define FWRITE          0x0002
  40. #define O_NONBLOCK      0x0004          /* no delay */
  41. #define O_APPEND        0x0100          /* set append mode */
  42. #ifndef _POSIX_SOURCE
  43.   #define O_SHLOCK        0x0           /* open with shared file lock */
  44.   #define O_EXLOCK        0x0           /* open with exclusive file lock */
  45.   #define O_ASYNC         0x0040        /* signal pgrp when data ready */
  46.   #define O_FSYNC         0x2000        /* synchronous writes */
  47.   #define O_CASE          0x1000        /* open file using a case-sensitive filename */
  48. #endif
  49. #define O_CREAT         0x0200          /* create if nonexistant */
  50. #define O_TRUNC         0x0400          /* truncate to zero length */
  51. #define O_EXCL          0x0800          /* error if already exists */
  52. #define FEXTOPEN        0x0010          /* don't close with DOS Close command */
  53. #define FUNLINK         0x0080          /* unlink file when closed */
  54. #define FMARK           0x0             /* mark during gc() */
  55. #define FDEFER          0x0             /* defer for next gc pass */
  56. #define FHASLOCK        0x0             /* descriptor holds advisory lock */
  57.  
  58. /* defined by POSIX 1003.1; BSD default, so no bit required */
  59. #define O_NOCTTY        0               /* don't assign controlling terminal */
  60.  
  61. /*
  62.  * The O_* flags used to have only F* names, which were used in the kernel
  63.  * and by fcntl.  We retain the F* names for the kernel f_flags field
  64.  * and for backward compatibility for fcntl.
  65.  */
  66. #ifndef _POSIX_SOURCE
  67.   #define FAPPEND         O_APPEND        /* kernel/compat */
  68.   #define FASYNC          O_ASYNC         /* kernel/compat */
  69.   #define FFSYNC          O_FSYNC         /* kernel */
  70.   #define FNONBLOCK       O_NONBLOCK      /* kernel */
  71.   #define FNDELAY         O_NONBLOCK      /* compat */
  72.   #define FNBIO           O_NONBLOCK      /* compat */
  73.   #define O_NDELAY        O_NONBLOCK      /* compat */
  74. #endif
  75.  
  76. #define FOPEN           (-1)
  77. /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
  78. #define FFLAGS(oflags)  ((oflags) + 1)
  79. #define OFLAGS(fflags)  ((fflags) - 1)
  80.  
  81. /* bits to save after open */
  82. #define FMASK           (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  83. /* bits settable by fcntl(F_SETFL, ...) */
  84. #define FCNTLFLAGS      (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  85.  
  86.  
  87. /* file descriptor flags (F_GETFD, F_SETFD) */
  88. #define FD_CLOEXEC      1               /* close-on-exec flag */
  89.  
  90. int     creat (cchar *, mode_t);
  91. int     open  (cchar *, int, ...);
  92.  
  93. #ifdef __cplusplus
  94.   }
  95. #endif
  96.  
  97. #ifdef STORMAMIGA_UNIXPATH
  98.   __inline int creat_u (cchar *path, mode_t mode)
  99.   { return creat       (path, mode);}
  100.  
  101.   __inline int open_u  (cchar *path, int flags)
  102.   { return open        (path, flags); }
  103.  
  104.   #define creat(path, mode) creat_u(UnixToAmigaPath(file), mode)
  105.   #define open(path, flags) open_u(UnixToAmigaPath(file), flags)
  106. #endif
  107.  
  108. #endif /* FCNTL_H */
  109.